package com.practice.controller.user;

import com.practice.common.result.Result;
import com.practice.pojo.user.dto.*;
import com.practice.service.user.UUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Jasmine
 * @since 2023-05-14
 */
@RestController("uUserController")
@RequestMapping("/user")
public class UserController {
    
    @Autowired
    private UUserService uUserService;
    
    @GetMapping("/myArticle")
    public Result myArticle(PageQueryDTO dto){
        return uUserService.myArticle(dto);
    } 
    @GetMapping("/getUserInfo")
    public Result getUserInfo(){
        return uUserService.getUserInfo();
    }
    @GetMapping("/userDataList")
    public Result userDataList(PageQueryDTO dto){
        return uUserService.userDataList(dto);
    }
    @PostMapping("/editArticle")
    public Result editArticle(@RequestBody ArticleDTO dto){
        uUserService.editArticle(dto);
        return Result.success();
    }
    @PostMapping("/update")
    public Result update(@RequestBody UserDTO dto){
        uUserService.update(dto);
        return Result.success();
    }

    @GetMapping("/userDataHandle")
    public Result userDataHandle(UserHandleDTO dto){
        uUserService.userDataHandle(dto);
        return Result.success();
    }
    @PostMapping("/addArticle")
    public Result addArticle(@RequestBody UserArticleDTO dto){
        uUserService.addArticle(dto);
        return Result.success();
    }

    @GetMapping("/delArticle")
    public Result delArticle(Long id){
        uUserService.delArticle(id);
        return Result.success();
    }
}
